package com.gxa.community.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.community.admin.mapper.OperateFullGoodsRelMapper;
import com.gxa.community.admin.mapper.OperateFullMapper;
import com.gxa.community.admin.service.OperateFullGoodsRelService;
import com.gxa.community.admin.service.OperateFullService;
import com.gxa.community.core.pojo.domain.OperateFull;
import com.gxa.community.core.pojo.domain.OperateFullGoodsRel;
import com.gxa.community.core.pojo.vo.FullAddVo;
import com.gxa.community.core.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 满减表 服务实现类
 * </p>
 *
 * @author XYJ
 * @since 2022-07-20
 */
@Service
public class OperateFullServiceImpl extends ServiceImpl<OperateFullMapper, OperateFull> implements OperateFullService {

    @Autowired
    private OperateFullMapper operateFullMapper;
    @Autowired
    private OperateFullGoodsRelService operateFullGoodsRelService;
    @Autowired
    private OperateFullGoodsRelMapper operateFullGoodsRelMapper;
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    public static final String GOODSDEL = "GoodsDel:";

    @Override
    public R queryFull(int page,int size) {
            //        System.out.println(page+" "+size);
            Page<OperateFull> page1 = new Page<>(page,size);
            Page<OperateFull> operateFull = this.page(page1, null);
            List<OperateFull> list = operateFull.getRecords();
//        List<OperateFull> list = this.list();
            List<OperateFull> operateFull1s =new ArrayList<>();
            for (OperateFull fullList : list) {
                OperateFull operateFull1 = new OperateFull();
                operateFull1.setId(fullList.getId());
                operateFull1.setName(fullList.getName());
                operateFull1.setType(fullList.getType());
                operateFull1.setUseType(fullList.getUseType());
                operateFull1.setFirst(fullList.getFirst());
                operateFull1.setUseThreshold(fullList.getUseThreshold());
                operateFull1.setSecond(fullList.getSecond());
                operateFull1.setUseRange(fullList.getUseRange());
                operateFull1.setUseWay(fullList.getUseWay());
                operateFull1.setOperateUse(fullList.getOperateUse());
                operateFull1.setFullNo(fullList.getFullNo());
                Long startTime = fullList.getStartTime();//获取活动开始时间
                Long endTime = fullList.getEndTime();//获取活动结束时间
                operateFull1.setStartTime(startTime);
                operateFull1.setEndTime(endTime);
                operateFull1.setRemark(fullList.getRemark());
                long nowTime = new Date().getTime();//获取当前时间
                if (startTime<=nowTime && nowTime <= endTime){
                    operateFull1.setStatus(0);//进行中
                    //同时修改一下数据库的值
                    operateFullMapper.updatestatus(0,fullList.getId());
                }if (nowTime<startTime){
                    operateFull1.setStatus(-1);//未进行
                    operateFullMapper.updatestatus(-1,fullList.getId());
                }if (nowTime>endTime){
                    operateFull1.setStatus(1);//已结束
                    operateFullMapper.updatestatus(1,fullList.getId());
                }
                operateFull1s.add(operateFull1);
            }
            return R.ok().put("data",operateFull1s);

    }

    @Override
    public R addFull(FullAddVo fullAddVo) {
        if (fullAddVo!=null){
        //将fullAddVo中的值全部取出
        OperateFull operateFull = new OperateFull();
        operateFull.setEndTime(fullAddVo.getEndTime());
        BigDecimal first = fullAddVo.getFirst();  //满....
        operateFull.setFirst(first);
        operateFull.setFullNo(fullAddVo.getFullNo());
        operateFull.setName(fullAddVo.getName());
        operateFull.setOperateUse(fullAddVo.getOperateUse());
        operateFull.setRemark(fullAddVo.getRemark());
        BigDecimal second = fullAddVo.getSecond();  //减。。。。
        operateFull.setSecond(second);
        operateFull.setStartTime(fullAddVo.getStartTime());
        operateFull.setUseType(fullAddVo.getUseType());
        Integer type = fullAddVo.getType();//获得满减类型
        operateFull.setType(type);
        operateFull.setUseRange(fullAddVo.getUseRange());
        operateFull.setUseWay(fullAddVo.getUseWay());
        if (type==1){
            operateFull.setUseThreshold(first+"件免"+second+"件");
        }else{
            operateFull.setUseThreshold("满"+first+"减"+second);
        }
            //删除前前台redis删除
//            String message = "活动改变请删除redis";
            jmsMessagingTemplate.convertAndSend(GOODSDEL,new ArrayList<>());
        boolean save = this.save(operateFull);
        //获得满减商品的list
        List<OperateFullGoodsRel> operateFullGoodsRels = fullAddVo.getOperateFullGoodsRels();
        boolean b = operateFullGoodsRelService.saveBatch(operateFullGoodsRels);
        if (save&&b){
            return R.ok("添加满减成功");
        }
        }
        return R.error(502,"添加失败，传输的实体为null");
    }

    @Override
    public R delFull(String fullNo) {
        //先根据fullNo找到status
        QueryWrapper<OperateFull> wrapper = new QueryWrapper<>();
        wrapper.eq("full_no",fullNo);
        OperateFull operateFull = operateFullMapper.selectOne(wrapper);
        if (operateFull!=null){
            Integer status = operateFull.getStatus();
            System.out.println(status+"========"+operateFull);
            if (status==-1){
                //通过fullNo进行删除
                HashMap<String,Object> map = new HashMap<>();
                map.put("full_no",fullNo);
                //删除前前台redis删除
                //            String message = "活动改变请删除redis";
                jmsMessagingTemplate.convertAndSend(GOODSDEL,new ArrayList<>());
                int i = operateFullMapper.deleteByMap(map);
                //删除相关商品
                operateFullGoodsRelMapper.deleteByMap(map);
                if (i>0){
                    return R.ok("删除成功");
                }return R.error(407,"删除失败，请检查编号");
            }return R.error(306,"只能删除未开始的满减");
        }
       return R.error(503,"失败,请检查满减编号是否有误");
    }

    @Override
    public R preEdit(String fullNo) {
        //根据fullNo查询1条实体类数据
        QueryWrapper<OperateFull> wrapper = new QueryWrapper<>();
        wrapper.eq("full_no",fullNo);
        OperateFull operateFull = operateFullMapper.selectOne(wrapper);
        //根据fullNo查询所有的相关商品
        QueryWrapper<OperateFullGoodsRel> goodswrapper = new QueryWrapper<>();
        goodswrapper.eq("full_no",fullNo);
        List<OperateFullGoodsRel> operateFullGoodsRels = operateFullGoodsRelMapper.selectList(goodswrapper);
        FullAddVo fullAddVo = new FullAddVo();
        fullAddVo.setEndTime(operateFull.getEndTime());
        fullAddVo.setFirst(operateFull.getFirst());
        fullAddVo.setFullNo(operateFull.getFullNo());
        fullAddVo.setName(operateFull.getName());
        fullAddVo.setOperateUse(operateFull.getOperateUse());
        fullAddVo.setRemark(operateFull.getRemark());
        fullAddVo.setSecond(operateFull.getSecond());
        fullAddVo.setStartTime(operateFull.getStartTime());
        fullAddVo.setUseType(operateFull.getUseType());
        fullAddVo.setUseWay(operateFull.getUseWay());
        fullAddVo.setType(operateFull.getType());
        fullAddVo.setUseRange(operateFull.getUseRange());
        //回显相关商品
//        List<OperateFullGoodsRel> operateFullGoodsRels1 = new ArrayList<>();
//        for (OperateFullGoodsRel ofgr : operateFullGoodsRels) {
//            OperateFullGoodsRel operateFullGoodsRel = new OperateFullGoodsRel();
//            operateFullGoodsRel.setFullNo(fullNo);
//            operateFullGoodsRel.setGoodsName(ofgr.getGoodsName());
//            operateFullGoodsRel.setNo(ofgr.getNo());
//            operateFullGoodsRel.setId(ofgr.getId());
//            operateFullGoodsRels1.add(operateFullGoodsRel);
//        }
        fullAddVo.setOperateFullGoodsRels(operateFullGoodsRels);
        return R.ok().put("data",fullAddVo);
    }

    @Override
    public R editFull(FullAddVo fullAddVo) {
        if (fullAddVo!=null){
            //首先获取fullNo
            String fullNo = fullAddVo.getFullNo();
            //先根据fullNo找到status
            QueryWrapper<OperateFull> wrapper = new QueryWrapper<>();
            wrapper.eq("full_no",fullNo);
            OperateFull operateFull1 = operateFullMapper.selectOne(wrapper);
            if (operateFull1!=null) {
                Integer status = operateFull1.getStatus();
                if (status == -1) {
                    HashMap<String,Object> map = new HashMap<>();
                    map.put("full_no",fullNo);
                    //通过fullNo将秒杀删除
                    int i = operateFullMapper.deleteByMap(map);
                    System.err.println("删除"+i);
                    //删除相关商品
                    int i1 = operateFullGoodsRelMapper.deleteByMap(map);
                    System.err.println("删除"+i1);
                    //开始进行添加
                    //将fullAddVo中的值全部取出
                    OperateFull operateFull = new OperateFull();
                    operateFull.setEndTime(fullAddVo.getEndTime());
                    BigDecimal first = fullAddVo.getFirst();  //满....
                    operateFull.setFirst(first);
                    operateFull.setFullNo(fullAddVo.getFullNo());
                    operateFull.setName(fullAddVo.getName());
                    operateFull.setOperateUse(fullAddVo.getOperateUse());
                    operateFull.setRemark(fullAddVo.getRemark());
                    BigDecimal second = fullAddVo.getSecond();  //减。。。。
                    operateFull.setSecond(second);
                    operateFull.setStartTime(fullAddVo.getStartTime());
                    operateFull.setUseType(fullAddVo.getUseType());
                    Integer type = fullAddVo.getType();//获得满减类型
                    operateFull.setType(type);
                    operateFull.setUseRange(fullAddVo.getUseRange());
                    operateFull.setUseWay(fullAddVo.getUseWay());
                    if (type==1){
                        operateFull.setUseThreshold(first+"件免"+second+"件");
                    }if (type==2){
                        operateFull.setUseThreshold("满"+first+"减"+second);
                    }
                    //删除前前台redis删除
//            String message = "活动改变请删除redis";
                    jmsMessagingTemplate.convertAndSend(GOODSDEL,new ArrayList<>());
                    boolean save = this.save(operateFull);
                    //获得满减商品的list
                    List<OperateFullGoodsRel> operateFullGoodsRels = fullAddVo.getOperateFullGoodsRels();
                    boolean b = operateFullGoodsRelService.saveBatch(operateFullGoodsRels);
                    if (save&&b){
                        return R.ok("修改满减成功");
                    }

                }
                return R.error(306,"只能修改未开始的满减");
            }
        }
        return R.error(503,"修改失败,传输的实体为null");
    }

    @Override
    public R textFull(String name, Integer status, Long startTime, Long endTime, Integer page, Integer size) {
        if (page!=null&&size!=null){
            Page<OperateFull> page1 = new Page<>(page,size);
            QueryWrapper<OperateFull> wrapper = new QueryWrapper<>();
            if (status==null){
                return R.error(500,"status不能为null -1未进行 0进行中 1已结束 2全部");
            }else
            if (status==2&&name==null&&startTime==null&&endTime==null){
                Page<OperateFull> operateFull = this.page(page1, null);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if (name.length()!=0&&startTime==null&&endTime==null&&status==2){
                //根据fullNo查询1条实体类数据

                wrapper.like("name",name);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if (name.length()!=0&&startTime!=null&&endTime!=null&&status==2){
                //根据fullNo查询1条实体类数据
                wrapper.like("name",name);
                wrapper.ge("start_time",startTime);
                wrapper.le("end_time",endTime);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if (name.length()==0&&startTime!=null&&endTime!=null&&status==2){
                //根据fullNo查询1条实体类数据
                wrapper.ge("start_time",startTime);
                wrapper.le("end_time",endTime);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if(name.length()!=0&&startTime!=null&&endTime!=null&&status!=2){
                //根据fullNo查询1条实体类数据
                wrapper.like("name",name);
                wrapper.ge("start_time",startTime);
                wrapper.le("end_time",endTime);
                wrapper.eq("status",status);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if(name.length()==0&&startTime!=null&&endTime!=null&&status!=2){
                //根据fullNo查询1条实体类数据
                wrapper.ge("start_time",startTime);
                wrapper.le("end_time",endTime);
                wrapper.eq("status",status);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }else
            if(name.length()==0&&startTime==null&&endTime==null&&status!=2){
                //根据fullNo查询1条实体类数据
                wrapper.eq("status",status);
                Page<OperateFull> operateFull = this.page(page1, wrapper);
                List<OperateFull> list = operateFull.getRecords();
                List<OperateFull> operateFull1s =new ArrayList<>();
                for (OperateFull fullList : list) {
                    OperateFull operateFull1 = new OperateFull();
                    operateFull1.setId(fullList.getId());
                    operateFull1.setName(fullList.getName());
                    operateFull1.setType(fullList.getType());
                    operateFull1.setUseType(fullList.getUseType());
                    operateFull1.setFirst(fullList.getFirst());
                    operateFull1.setUseThreshold(fullList.getUseThreshold());
                    operateFull1.setSecond(fullList.getSecond());
                    operateFull1.setUseRange(fullList.getUseRange());
                    operateFull1.setUseWay(fullList.getUseWay());
                    operateFull1.setOperateUse(fullList.getOperateUse());
                    Long startTime1 = fullList.getStartTime();//获取活动开始时间
                    Long endTime1 = fullList.getEndTime();//获取活动结束时间
                    operateFull1.setStartTime(startTime1);
                    operateFull1.setEndTime(endTime1);
                    operateFull1.setRemark(fullList.getRemark());
                    long nowTime = new Date().getTime();//获取当前时间
                    if (startTime1<=nowTime && nowTime <= endTime1){
                        operateFull1.setStatus(0);//进行中
                        //同时修改一下数据库的值
                        operateFullMapper.updatestatus(0,fullList.getId());
                    }if (nowTime<startTime1){
                        operateFull1.setStatus(-1);//未进行
                        operateFullMapper.updatestatus(-1,fullList.getId());
                    }if (nowTime>endTime1){
                        operateFull1.setStatus(1);//已结束
                        operateFullMapper.updatestatus(1,fullList.getId());
                    }
                    operateFull1s.add(operateFull1);
                }
                return R.ok().put("data",operateFull1s);
            }
            else return R.error(505,"startTime和endTime不能单独一个为null");
        }
        return R.error(601,"page和size不能为null");
    }

   /* @Override
    public R delFull(String fullNo) {
        //先判断状态 根据fullNo查找当前状态
        QueryWrapper<OperateFull> wrapper = new QueryWrapper<>();
        wrapper.eq("full_no",fullNo);
        OperateFull operateFull = operateFullMapper.selectOne(wrapper);
        if (operateFull!=null){
            Integer status = operateFull.getStatus();
            if (status==-1){
                HashMap<String,Object> map = new HashMap<>();
                map.put("full_no",fullNo);
                int i = operateFullMapper.deleteByMap(map);
                if (i>0){
                    return R.ok("删除成功");
                }return R.error(503,"未成功请检查满减编号");
            }
            return R.error(306,"只能删除未进行的满减");
        }
        return R.error(501,"失败，请检查满级按编号");
    }*/


}
